import Vue from 'vue';
import App from './App';
import common from './utils/common.js'  

import userinfo from "appComponent/platcommon/userinfo";
Vue.component('userinfo', userinfo);

import tabbar from "appComponent/platcommon/tabbar";
Vue.component('tabbar', tabbar);

import lang from "appComponent/platcommon/lang";
Vue.component('lang', lang);

import currency from "appComponent/platcommon/currency";
Vue.component('currency', currency);

// import html_parse from "./pages/index/html_parse.vue";
// Vue.component('html_parse', html_parse);

import auth_btn from "./pages/public/auth_btn.vue";
Vue.component('auth_btn', auth_btn);

// import webtemplate from "./pages/webview/webtemplate.vue";
// Vue.component('webtemplate', webtemplate);
 
// #ifdef H5
try{
	if (common.$checkPlat.checkAlipay()) {
		document.writeln('<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"' + '>' + '<' + '/' + 'script>');
	}
	if (common.$checkPlat.checkAlipayApp()) {
		App.globalData.isAliapp = true
		document.writeln('<script src="https://appx/web-view.min.js"' + '>' + '<' + '/' + 'script>');
	}
	if (common.$checkPlat.checkWeixinApp()) {
		App.globalData.isWxapp = true
	}
	
	
}catch(e){ 
	console.log('9999999加载额外的js', e)
}
// document.writeln('<script src="http://imgcache.qq.com/open/qcloud/video/vcplayer/TcPlayer-2.3.2.js"></script>')

// ios 设备进入页面则进行js-sdk签名
if (common.$checkPlat.checkWeixin() && common.$checkPlat.checkIos()) {
  common.getWxconfig()
}

import {Watch} from './utils/watch.js'
// 全局变量
var res = JSON.parse(window.sessionStorage.getItem('pigo2o_globalData'))
if (res) {
  for (var i in res) {
	  if (i != 'open_multilingual') {
		  App.globalData[i] = res[i]
	  }
	  if (i == 'userInfo' && res[i]) {
		  window.localStorage.setItem('packapp_user', JSON.stringify(res[i]))
		  
	  }
  }
}
// 监听全局变量的变化
var watchedGlobalData = new Watch(App.globalData, callback)
function callback (path, newVal, oldVal) {
  setTimeout(function () {
    window.sessionStorage.setItem('pigo2o_globalData', JSON.stringify(App.globalData))
  }, 0)
}
// #endif

Vue.config.productionTip = false; 
App.mpType = 'app';

const app = new Vue({
    ...App
});
app.$mount();
